<template>
  <div class="home">
    <el-container style="height: 500px; border: 1px solid #eee">
      <el-aside width="200px" style="background:#334358">
        <el-menu :default-openeds="['1', '3']">
          <el-submenu index="0">
            <template slot="title">
              <i class="el-icon-menu"></i>首页
            </template>
          </el-submenu>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-document-remove"></i>数据管理
            </template>
            <el-menu-item index="1-1" @click="userlist">用户列表</el-menu-item>
            <el-menu-item index="1-2" @click="shoplist">商家列表</el-menu-item>
            <el-menu-item index="1-3">食品列表</el-menu-item>
            <el-menu-item index="1-4">订单列表</el-menu-item>
            <el-menu-item index="1-5">管理员列表</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-folder-add"></i>添加数据
            </template>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-star-on"></i>图表
            </template>
          </el-submenu>
           <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-edit"></i>编辑
            </template>
          </el-submenu>
           <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-s-tools"></i>设置
            </template>
          </el-submenu>
           <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-warning"></i>说明
            </template>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container>
        <el-header style="text-align: left; font-size: 12px">
          首页  /   数据展示   /  
          <span v-show="isShow">商家列表</span>
          <span v-show="!isShow">用户列表</span>
        </el-header>
        <p class="addStore">
          <input type="text" placeholder="店铺名称" v-model="name">
          <input type="text" placeholder="店铺地址" v-model="address">
          <input type="text" placeholder="店铺描述" v-model="description">
          <button @click="addStore">添加</button>
        </p>
        <p class="addStore2">
          <input type="text" placeholder="请输入要查找的店铺名" v-model="searchs">
          <button @click="search">查找</button>
        </p>
        <el-main>
          <Userlist v-show="!isShow"></Userlist>
          <Shoplist v-show="isShow"></Shoplist>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import Userlist from "../components/Userlist";
import Shoplist from "../components/Shoplist";
export default {
  components:{
    Shoplist,Userlist
  },
  data() {
    const item = {
      date: "2016-05-02",
      name: "王小虎",
      address: "上海市普陀区金沙江路 1518 弄"
    };
    return {
      tableData: Array(20).fill(item),
      isShow:true,
      name:"",
      address:"",
      description:"",
      searchs:""
    };
  },
  methods:{
    userlist(){
      this.isShow=false
    },
     shoplist(){
      this.isShow=true
    },
    addStore(){
      let store = {
        name:this.name,
        address:this.address,
        description:this.description
      }

      this.$store.dispatch("add_store",store)
      this.name=""
      this.address=""
      this.description=""
    },
    search(){
      this.$store.dispatch("to_search",this.searchs)
    }
  }
};
</script>
<style>
.el-header {
  background-color: #ced5df;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;

}
.addStore{
  width: 100%;
  height: 30px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #eeeeee;
}
.addStore input{
  width: 200px;
}
.addStore button{
  width: 100px;
  text-align: center;
}
.addStore2{
  width: 100%;
  height: 30px;
  display: flex;
  justify-content: left;
  border-bottom: 1px solid #eeeeee;
}
.addStore2 input{
  width: 200px;
}
.addStore2 button{
  width: 100px;
  text-align: center;
  margin-left: 210px;
}
</style>
